﻿using ChatBackend.Common.Enums;
using ChatBackend.Services.LoginService;
using Microsoft.AspNetCore.Mvc;

namespace ChatBackend.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class LoginController : ControllerBase
    {
        private readonly ILoginService _loginService;

        public LoginController(ILoginService loginService)
        {
            _loginService = loginService;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<bool> RegisteredAccount(string userName, string UID, string PWD)
        {
            return await _loginService.RegisteredAccount(userName, UID, PWD, Gender.Male);
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="UID">账号</param>
        /// <param name="PWD">密码</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<bool> Login(string UID, string PWD)
        {
            return await _loginService.Login(UID, PWD);
        }
    }
}